
const { ccclass, property } = cc._decorator;

@ccclass
export default class CoinItem extends cc.Component {
    @property(cc.Node)
    private itemNode: cc.Node = null;
    @property(cc.SpriteFrame)
    private FrameArr:cc.SpriteFrame[] = []
    start(){
        
    }
    public resize(){
        let isVerTical = cc.winSize.height > cc.winSize.width
        if(this.itemNode==null){
            return
        }else{
            this.itemNode.x = isVerTical ? 0 : -cc.winSize.width / 3.5
        }
    }
    public initItem(isBottom:boolean){
        if(!isBottom){
            this.itemNode.x = this.getRandomInt(-100,100)
            this.itemNode.y = this.getRandomInt(-50,50)
        }else{
            this.itemNode.x = this.getRandomInt(-320,320)
            this.itemNode.y = this.getRandomInt(-100,50)
        }
        this.itemNode.scale = this.getRandomInt(5,10)*0.1
        let index = this.getRandomInt(0,5)
        this.itemNode.getComponent(cc.Sprite).spriteFrame = this.FrameArr[index]
    }
    private getRandomInt(min: number, max: number) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }
    protected onDisable(): void {
    }
}

